/*
 * @Author: 追逐的娃 kangchao_php@163.com
 * @Date: 2024-04-30 13:45:21
 * @LastEditors: 追逐的娃 kangchao_php@163.com
 * @LastEditTime: 2024-05-06 11:26:33
 * @FilePath: \huijie-admin\vite.config.js
 * @Description: 
 * 
 */
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import {fileURLToPath,URL} from 'node:url'
//引入windicss
import WindiCSS from 'vite-plugin-windicss'
//引入elementPlus按需导入
import AutoImport from 'unplugin-auto-import/vite'
import Components from 'unplugin-vue-components/vite'
import { ElementPlusResolver } from 'unplugin-vue-components/resolvers'


// https://vitejs.dev/config/
export default defineConfig({
  plugins: [
    vue(),
    WindiCSS(),
    AutoImport({
      resolvers: [ElementPlusResolver()],
    }),
    Components({
      resolvers: [ElementPlusResolver()],
    }),
  ],
  resolve: {
    alias:{
      '@': fileURLToPath(new URL('./src',import.meta.url))
    }
  },
  //配置跨域问题
  server: {
    proxy: {
      '/api': {
        target: 'http://admin-api.demo.com',
        changeOrigin: true,
        rewrite: (path) => path.replace(/^\/api/,'')
      }
    }
  }
})
